﻿using System;
using System.Collections.Generic; 
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;

public partial class history_lottery : System.Web.UI.Page
{
    protected int type = ReadRequest.RequestInt("type");
    protected List<Model.LotteryAnnouncement> lotteryAn = null;
    protected decimal userbuybuyMoney = 0;
    protected List<Model.LotteryBuyDetail> userbuy = null;

    protected List<Model.LotteryAnnouncement> curModelLottery = null; 
    protected decimal curModelLotteryMoney = 0;

    protected void Page_Load(object sender, EventArgs e)
    {

        int curCount = 0;
        curModelLottery = BLL.LotteryAnnouncement.GetPageList_Where(0, 2, type, out curCount);
        if (curModelLottery != null)
        {
            //curModelLotteryMoney = bindTotal2(curModelLottery[0].LotteryQS);
            curModelLotteryMoney = curModelLottery[0].jiangChi;
        }
        if (!IsPostBack)
        {
           
            int totalCount = 0;
            lotteryAn = BLL.LotteryAnnouncement.GetPageList_Where(0, int.MaxValue, type, out totalCount);
            lotteryList.DataSource = lotteryAn;
            lotteryList.DataBind();
        }
    }
    public decimal bindTotal2(string qs)
    {
        int totalCount4 = 0;
        userbuy = BLL.LotteryBuyDetail.getlistbytypeandqs(0, int.MaxValue, type, qs, out totalCount4);
        if (userbuy != null)
        {
            for (int i = 0; i < userbuy.Count; i++)
            {
                userbuybuyMoney += userbuy[i].LotteryMoney;
            }
        }
        return userbuybuyMoney;
    }
    public string bindTotal(string qs)
    { 
        int totalCount4 = 0;
        userbuy = BLL.LotteryBuyDetail.getlistbytypeandqs(0, int.MaxValue, type, qs, out  totalCount4);
        if (userbuy != null)
        {
            for (int i = 0; i < userbuy.Count; i++)
            {
                userbuybuyMoney += userbuy[i].LotteryMoney;
            }
        }
        return userbuybuyMoney / 10000 > 1 ? (userbuybuyMoney / 10000).ToString("0.00") + "万元" : userbuybuyMoney + "元";
    }
    public string bindLebelMoney(decimal money)
    {
        return money / 10000 > 1 ? (money / 10000).ToString("0.00") + "万元" : money + "元"; ;
    }
    protected void seacgBtn_Click(object sender, EventArgs e)
    {
        if (IsNumber(qstxt.Text))
        {
            int totalCount = 0;
            lotteryAn = BLL.LotteryAnnouncement.GetPageList_Where(0, int.Parse(qstxt.Text), type, out totalCount);
            lotteryList.DataSource = lotteryAn;
            lotteryList.DataBind();
        }
        else
        {
            System.Web.HttpContext.Current.Response.Write("<script type=\"text/javascript\">alert('请输入数字！');</script>");
        }
    }
    public static bool IsNumber(string strNumber)
    {
        Regex regex = new Regex("[^0-9]");
        return !regex.IsMatch(strNumber);
    }
    public string bindLotteryNo(string LotteryNo)
    {
        string[] ssqflaglist = LotteryNo.Split('+');
        string[] SSQList = null;
        string[] SSQListBlue = null;
        string SSQblue = null;
        SSQList = ssqflaglist[0].Split(',');
        if (ssqflaglist.Length == 2 && SSQList.Length == 6)
        {
            SSQblue = ssqflaglist[1];
            return "<li>" + SSQList[0]
                + "</li><li>" + SSQList[1]
                + "</li><li>" + SSQList[2]
                + "</li><li>" + SSQList[3]
                + "</li><li>" + SSQList[4]
                + "</li><li>" + SSQList[5] + "</li><li class=\"last_l\">" + SSQblue + "</li>";
        }else if (ssqflaglist.Length == 2 && SSQList.Length == 5)
        {
            SSQListBlue = ssqflaglist[1].Split(',');
            return "<li>" + SSQList[0]
                + "</li><li>" + SSQList[1]
                + "</li><li>" + SSQList[2]
                + "</li><li>" + SSQList[3]
                + "</li><li>" + SSQList[4]
                + "</li><li class=\"last_l\">" + SSQListBlue[0] + "</li><li class=\"last_l\">" + SSQListBlue[1] + "</li>";
        }
        else if (ssqflaglist.Length == 2 && SSQList.Length == 7)
        {
            SSQblue = ssqflaglist[1];
            return "<li>" + SSQList[0]
                + "</li><li>" + SSQList[1]
                + "</li><li>" + SSQList[2]
                + "</li><li>" + SSQList[3]
                + "</li><li>" + SSQList[4]
                + "</li><li>" + SSQList[5]
                + "</li><li>" + SSQList[6] + "</li><li class=\"last_l\">" + SSQblue + "</li>";
        }
        else
        {
            string str = "<li>";
            for (int i = 0; i < SSQList.Length; i++)
            {
                str +=SSQList[i]+ "</li><li>";
            }
            return str.Substring(0,str.Length-4);
        } 
    }
}